<template>
  <div id="element">
    <el-table
      :data="tableData"
      border
      style="width: 100%; background: transparent"
      :header-cell-style="headerCellStyle"
      :cell-style="cellStyle"
    >
      <el-table-column prop="date" label="日期" width="150" align="center"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="120" align="center">
      </el-table-column>
      <el-table-column prop="province" label="省份" width="120" align="center">
      </el-table-column>
      <el-table-column prop="city" label="市区" width="120" align="center">
      </el-table-column>
      <el-table-column prop="address" label="地址" align="center">
      </el-table-column>
      <el-table-column prop="zip" label="邮编" width="120" align="center">
      </el-table-column>
      <el-table-column label="操作" width="100" align="center">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >查看</el-button
          >
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="flex">
      <div class="block">
        <el-carousel height="440px">
          <el-carousel-item v-for="(item, index) in imgList" :key="index">
            <img
              :src="imgList[index].url"
              width="330px"
              height="440px"
              align="middle"
              style="objectfit: cover"
              alt=""
            />
          </el-carousel-item>
        </el-carousel>
      </div>
      <el-card class="box-card">
        <el-button
          v-for="(item, index) in btns"
          :key="index"
          class="btn"
          :style="item == 'element' ? 'display:none' : ''"
          @click="btn(item)"
          >{{ item }}</el-button
        >
      </el-card>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  computed: {
    ...mapState({
      btns: (state) => state.vuex.btns,
    }),
  },
  created() {
    for (let index = 1; index <= 4; index++) {
      let obj = { url: require(`@/assets/c${index}.png`) };
      this.imgList.push(obj);
    }
  },
  data() {
    return {
      tableData: [
        {
          date: "1996-08-27",
          name: "大孝子",
          province: "南京市",
          city: "XX区",
          address: "南京市XX区XX路XX号",
          zip: 210000,
        },
        {
          date: "1996-08-27",
          name: "大孝子",
          province: "南京市",
          city: "XX区",
          address: "南京市XX区XX路XX号",
          zip: 210000,
        },
        {
          date: "1996-08-27",
          name: "大孝子",
          province: "南京市",
          city: "XX区",
          address: "南京市XX区XX路XX号",
          zip: 210000,
        },
        {
          date: "1996-08-27",
          name: "大孝子",
          province: "南京市",
          city: "XX区",
          address: "南京市XX区XX路XX号",
          zip: 210000,
        }
      ],
      imgList: [],
    };
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },
    cellStyle() {
      return {
        background: "transparent",
      };
    },
    headerCellStyle() {
      return {
        background: "transparent",
        color: "#fff",
      };
    },
    btn(val) {
      this.$router.push(`/${val}`);
    },
  },
};
</script>

<style lang="scss" scoped>
#element {
  position: relative;
  width: 100%;
  height: 100%;
  background-image: url("@/assets/felix.png");
  background-size: cover;
  background-position: center;
  filter: brightness(66%);
  overflow-y: auto;

  :deep(tr) {
    background-color: transparent;
  }
  :deep(.el-table__body-wrapper) tr:hover {
    background-color: rgba($color: #000000, $alpha: 0.6) !important;
    color: #fff;
  }

  .flex {
    display: flex;
    justify-content: space-between;
    height: 440px;
    margin-top: 10px;
    padding: 0 10px;

    .block {
      width: 330px;
      height: 440px;
    }

    .box-card {
      width: 140px;
      height: 440px;
      background-color: transparent;
      :deep(.el-card__body) {
        text-align: center;
      }
      .btn {
        width: 100px;
        margin: 0 0 5px;
        background-color: transparent;
        color: #fff;
        &:hover {
          background-color: rgba($color: #000, $alpha: 0.6);
        }
      }
    }
  }
}
</style>